/*    */ package com.newcrm.util;
/*    */ 
/*    */ import java.io.IOException;
/*    */ import java.io.InputStream;
/*    */ import java.io.OutputStream;
/*    */ import java.util.Random;
/*    */ import java.util.Scanner;
/*    */ 
/*    */ public class Hardware4Win
/*    */ {
/* 10 */   private static String sn = null;
/*    */   public static final String numberUpperLetterChar = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/*    */ 
/*    */   public String getRandomNumberUpperLetterChar(int n)
/*    */   {
/* 15 */     StringBuffer sb = new StringBuffer();
/* 16 */     Random random = new Random();
/* 17 */     for (int i = 0; i < n; i++) {
/* 18 */       sb.append("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(random
/* 19 */         .nextInt("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".length())));
/*    */     }
/* 21 */     return sb.toString();
/*    */   }
/*    */ 
/*    */   public final String getSerialNumber()
/*    */   {
/* 26 */     if (sn != null) {
/* 27 */       return sn;
/*    */     }
/*    */ 
/* 30 */     OutputStream os = null;
/* 31 */     InputStream is = null;
/*    */ 
/* 33 */     Runtime runtime = Runtime.getRuntime();
/* 34 */     Process process = null;
/*    */     try {
/* 36 */       process = runtime.exec(new String[] { "wmic", "bios", "get", 
/* 37 */         "serialnumber" });
/*    */     } catch (IOException e) {
/* 39 */       throw new RuntimeException(e);
/*    */     }
/*    */ 
/* 42 */     os = process.getOutputStream();
/* 43 */     is = process.getInputStream();
/*    */     try
/*    */     {
/* 46 */       os.close();
/*    */     } catch (IOException e) {
/* 48 */       throw new RuntimeException(e);
/*    */     }
/*    */ 
/* 51 */     Scanner sc = new Scanner(is);
/*    */     try {
/* 53 */       while (sc.hasNext()) {
/* 54 */         String next = sc.next();
/* 55 */         if ("SerialNumber".equals(next)) {
/* 56 */           sn = sc.next().trim();
/* 57 */           break;
/*    */         }
/*    */       }
/*    */     } finally {
/*    */       try {
/* 62 */         sc.close();
/* 63 */         is.close();
/*    */       } catch (IOException e) {
/* 65 */         throw new RuntimeException(e);
/*    */       }
/*    */     }
/*    */ 
/* 69 */     if (sn == null) {
/* 70 */       throw new RuntimeException("Cannot find computer SN");
/*    */     }
/*    */ 
/* 73 */     return sn;
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.util.Hardware4Win
 * JD-Core Version:    0.6.1
 */